home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4618 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.8 KB  |  62 lines

  1. Newsgroups: comp.lang.c++
  2. Path: cs.vu.nl!jalten
  3. From: jalten@cs.vu.nl (Alten JP)
  4. Subject: Re: READ THIS!!!!!!!!!!!
  5. Nntp-Posting-Host: kits.cs.vu.nl
  6. References: <4em5fs$a86@ixnews4.ix.netcom.com>
  7. Sender: news@cs.vu.nl
  8. Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
  9. Date: Wed, 31 Jan 1996 10:44:53 GMT
  10. X-Newsreader: TIN [version 1.2 PL2]
  11. Message-ID: <DM1KIt.3Jx.0.-s@cs.vu.nl>
  12.  
  13. Jeremy Johnston (jeremyx@ix.netcom.com) wrote:
  14.  
  15. :   ok....now that I have your attention i need some help.
  16. : I can't get the following command to work & the compiler says that the
  17. : constant has too many characters.
  18.  
  19. :   char dos;
  20. :     if(dos=='dir')
  21. :     goto b;
  22.  
  23. My oh my, you have my attention alright, but do I have yours?
  24. here we go:
  25. your "dos" variable is just one character, which will mean
  26. you can't compare it to a string.
  27. a string (like "dir") should be surrounded by these guys: "
  28. not by these '
  29. the latter will surround a character, so your code would work like
  30. this:
  31. char dos;
  32. if (dos=='d')
  33.     goto b;
  34.  
  35. but, then again, that's probably not what you want. How about:
  36. char* dos;
  37. // now do some things, especially assigning dos to a string
  38. if (strcmp(dos,"dir")==0)
  39.     goto b;
  40.  
  41. Now, a lot of C++ programmers don't like the use of "goto", 
  42. so try to figure out a different way to do this, it will
  43. not only help you to eliminate "goto" and make us happy,
  44. it will also help you thiink about what you really want your 
  45. program to do, and find some stucture in the framework of your
  46. program.
  47.  
  48. Any questions, or was it just a way to fool me?
  49.  
  50. Jelle Paul
  51.  
  52. PS, how about trying to get a book on C/C++? not to flame you,
  53. but really, it helps to get accustomed to C/C++
  54.  
  55.  
  56.  
  57.  
  58. +-------------------------------------------------------+
  59. | Jelle Paul Alten                |   jalten@cs.vu.nl   |
  60. | Vrije Universiteit Amsterdam    |                     |
  61. +-------------------------------------------------------+
  62.